#!/usr/bin/env python3
"""
快速启动脚本 - 文本格式化工具
"""

import sys
import os

def main():
    """快速启动主函数"""
    print("🚀 启动文本格式化工具...")
    
    try:
        # 添加src目录到Python路径
        current_dir = os.path.dirname(os.path.abspath(__file__))
        src_path = os.path.join(current_dir, 'src')
        sys.path.insert(0, src_path)
        
        # 导入并启动应用程序
        from src.ui.main_window import MainWindow
        from PyQt6.QtWidgets import QApplication
        from PyQt6.QtCore import Qt
        
        # 创建应用程序
        app = QApplication(sys.argv)
        app.setApplicationName("文本格式化工具")
        app.setApplicationVersion("1.0.0")
        
        # 启用高DPI缩放（PyQt6中这些属性已弃用，默认启用）
        # app.setAttribute(Qt.ApplicationAttribute.AA_EnableHighDpiScaling, True)
        # app.setAttribute(Qt.ApplicationAttribute.AA_UseHighDpiPixmaps, True)
        
        # 创建主窗口
        window = MainWindow()
        window.show()
        
        print("✅ 应用程序启动成功！")
        
        # 运行应用程序
        sys.exit(app.exec())
        
    except ImportError as e:
        print(f"❌ 导入错误: {e}")
        print("请确保已安装所有依赖: pip install -r requirements.txt")
        return 1
    except Exception as e:
        print(f"❌ 启动失败: {e}")
        import traceback
        traceback.print_exc()
        return 1

if __name__ == "__main__":
    sys.exit(main()) 